const databasePublic = require("./databasePublic");
const database = new databasePublic(); //获取数据库方法
const getResult = require("./getResult");
async function getToken(req, res, next) { //拦截token
  const findRes = await database.find({
    library: "admin",
    listName: "user",
    whereStr: { userId: req.body.userId },
  }).catch(err => {
    console.log(err, "登录");
  });
  (findRes && findRes.length && findRes[0].token === req.headers.token) ? next() : res.json(getResult.loginLose());
}



module.exports = {
  getToken,
}